<?php
require_once '../../classes/includeAll_Layer2.php';

//$sessionId = 5; //debug
//$isAdmin=true;
$vlanID  = filter_input(INPUT_POST,"vlanID");
if($vlanID == null || $vlanID == false|| !$isAdmin)
{
  echo "false";
  exit();
}
require '../../resources/getConnection.php';

$configSwitchesClass = new configSwitches($connection);
$switches = $configSwitchesClass->GetSwitchesWithVlan($vlanID);
if(count($switches) > 0)
{
    echo"Dieses Vlan kann nicht gelöscht werden. \nFolgende Switche benötigen dieses Vlan:\n";
    for($i=0; $i < count($switches) ; $i++)
    {
        echo"-" . $switches[$i]->Name ."\n";
    }
}  else 
{
if($configSwitchesClass->removeVlan($vlanID))
  echo "true";
else
  echo "false";
}


